package 简单;

import java.util.Arrays;

public class 分发饼干455 {

    public static void main(String[] args) {
        int[] g  = {4,3,2};
        int[] s  = {3,3};
        System.out.println(findContentChildren(g,s ));

    }

    public static int findContentChildren(int[] g, int[] s) {
        Arrays.sort(g);
        Arrays.sort(s);
        int count = 0;
        int j = 0;
        int i = 0;
        int m = g.length;
        int n = s.length;
        while (i < m && j < n){
            while (j < n && g[i] > s[j]){
                j++;
            }
            if (j<n){
                j++;
                i++;
                count++;
            }
        }

        return count;

    }
}
